<?php
	$keys = array_keys($_POST);
	$move_ids = array();
	foreach ($keys as $ids){
		if (strstr($ids, "item")){
			$move_ids[] = substr($ids, 5);
			$at_least_one = true;
		}
	}

	if ($at_least_one != true){
		oyster_log("ERROR", (string)$language->errors->value_22, "MonaLisa move_existing");
		$head->_template_assign("ERROR", (string)$language->errors->value_22);
	} else {
		if ($_POST["expo_to"] != "nil"){
			
			$expo_old = sqlite_open($_GET["expo"]);
			$move = array();
			foreach ($move_ids as $id){
 				$read_old = sqlite_array_query($expo_old, "SELECT * FROM expo WHERE (id='".$id."')", SQLITE_ASSOC);
 				$delete = sqlite_query($expo_old, "DELETE FROM expo WHERE (id='".$id."')");
 				$move[] = $read_old;
			}
			$expo_new = sqlite_open($_POST["expo_to"]);
			foreach ($move as $neighbor){
				echo $neighbor;
				$xibit = $neighbor[0]['exhibit'];
				$type = $neighbor[0]['type'];
 				$write = sqlite_query($expo_new, "INSERT INTO expo (exhibit, type) VALUES ('$xibit', '$type')");
			}
			sqlite_close($expo_old);
			sqlite_close($expo_new);
			
		} else {
			oyster_log("ERROR", (string)$language->errors->value_25, "MonaLisa move_existing");
			$head->_template_assign("ERROR", (string)$language->errors->value_25);
		}
	}

?>
